var margin_x, margin_y;
margin_x = view_xview[0] + 8;
margin_y = view_yview[0] + 8;
if (global.team_member_current_id > 0)
{
    if (global.control == 1) && (dialog_active == false) && (global.cutscene == false) && (instance_exists((global.team_member_current_id)) == true)
    {
        var team_current_name_string, team_current_hp_string, team_current_portrait, team_current_portrait_width, team_current_portrait_height;
        team_current_name_string = ((global.team_member_current_id).character_name);
        team_current_hp_string = "HP: " + string((global.team_member_current_id).character_hp[0]) + "/" + string((global.team_member_current_id).character_hp[1]);
        team_current_portrait = (global.team_member_current_id).character_sprite_portrait;
        team_current_portrait_width = sprite_get_width(team_current_portrait);
        team_current_portrait_height = sprite_get_height(team_current_portrait);
        draw_set_halign(fa_left);
        draw_background(bg_hud, view_xview[0], view_yview[0]);
        draw_sprite(team_current_portrait, 0, margin_x, margin_y);
        textbox_draw_text(margin_x + team_current_portrait_width + 4,margin_y + team_current_portrait_height - 16,team_current_name_string,c_white,0);
        textbox_draw_text(margin_x + team_current_portrait_width + 4,margin_y + team_current_portrait_height - 8,team_current_hp_string,c_white,1);
        if ((global.team_member_current_id).character_item_equipped != -1)
        {
            if (ds_list_find_value(global.inventory_current_id[0],((global.team_member_current_id).character_item_equipped))!=0)
            {
                var team_current_item_name_string, team_current_item_sprite, team_current_item_sprite_width, team_current_item_sprite_height;
                team_current_item_name_string = ds_grid_get(global.item,0,ds_list_find_value(global.inventory_current_id[0],((global.team_member_current_id).character_item_equipped)));
                team_current_item_sprite = inventory_item_get_sprite(((global.team_member_current_id).character_item_equipped));
                team_current_item_sprite_width = sprite_get_width(team_current_item_sprite);
                team_current_item_sprite_height = sprite_get_height(team_current_item_sprite);
                draw_sprite(team_current_item_sprite, 0, margin_x + ((team_current_portrait_width / 2) - (team_current_item_sprite_width / 2)), margin_y + team_current_portrait_height - sprite_get_bbox_top(team_current_item_sprite) + 4);
                textbox_draw_text(margin_x + team_current_portrait_width + 4, margin_y + team_current_portrait_height + 4, team_current_item_name_string, c_white, 2);
                if (ds_list_find_value(global.inventory_current_id[2],((global.team_member_current_id).character_item_equipped)) > 0)
                {
                    var team_current_item_gauge_full, team_current_item_gauge_value;
                    team_current_item_gauge_value = ds_list_find_value(global.inventory_current_id[2],((global.team_member_current_id).character_item_equipped));
                    team_current_item_gauge_full = ds_grid_get(global.item,4,ds_list_find_value(global.inventory_current_id[0],((global.team_member_current_id).character_item_equipped)));
                    draw_set_color(c_black);
                    draw_rectangle(margin_x + team_current_portrait_width + 5, margin_y + team_current_portrait_height + 12, margin_x + team_current_portrait_width + 5 +(team_current_item_gauge_value/team_current_item_gauge_full)*(64),margin_y + team_current_portrait_height + 13,false);
                    draw_set_color(c_white);
                    draw_rectangle(margin_x + team_current_portrait_width + 4, margin_y + team_current_portrait_height + 11, margin_x + team_current_portrait_width + 4 +(team_current_item_gauge_value/team_current_item_gauge_full)*(64),margin_y + team_current_portrait_height + 12,false);
                    textbox_draw_text(margin_x + team_current_portrait_width + 4, margin_y + team_current_portrait_height + 15, string(team_current_item_gauge_value) + "/" + string(team_current_item_gauge_full), c_white, 2);
                }
                else
                {
                    var team_current_item_quantity;
                    team_current_item_quantity = ds_list_find_value(global.inventory_current_id[1],((global.team_member_current_id).character_item_equipped));
                    textbox_draw_text(margin_x + team_current_portrait_width + 4, margin_y + team_current_portrait_height + 12, "x" + string(team_current_item_quantity), c_white, 2);
                }
            }
        }
    }
}
